package com.zkingsoft.actions.visitor;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.zkingsoft.actions.common.BaseController;
import com.zkingsoft.anotations.RemoveRequestToken;
import com.zkingsoft.anotations.SaveRequestToken;
import com.zkingsoft.model.AdvertisementColumn;
import com.zkingsoft.model.AdvertisementPosition;
import com.zkingsoft.model.ArticleType;
import com.zkingsoft.plugin.pojo.PaginationVO;
import com.zkingsoft.plugin.util.WebUtil;
import com.zkingsoft.pojo.AjaxResult;
import com.zkingsoft.services.ArticleTypeService;

/**
 * This field was generated by Zking.software.Codegen.
 * @date 2016-11-11 10:23
 */
@Controller
@RequestMapping(value = "/arTypeInterface")
public class ArTypeController extends BaseController{

	@Resource
	private ArticleTypeService currentService;
	
	/**
	 * 
	 * @Description:根据文章分类名称查询一级子分类
	 * @auther:罗袁宏
	 * @param articleTypeName 文章类型名称             
	 * @return
	 * 返回类型 :AjaxResult
	 * @date:2016年11月11日
	 */
 	@RequestMapping(value = "/arType")
	public @ResponseBody AjaxResult arType(ArticleType articleType) {
 		//判断是否传参
 		if("".equals(articleType.getArticleTypeName())){
 			return new AjaxResult(AjaxResult.STATUS_ERR, null, "参数不全");
 		}
 		//根据文章类型名称查找文章类型的所有信息
 		List<ArticleType> articleTypeList = currentService.findByModel(articleType);
 		//判断该文章类型是否存在
 		if(articleTypeList.size()<=0){
 			return new AjaxResult(AjaxResult.STATUS_ERR, null,"暂无数据");
 		}
 		//查找父级ID为该文章类型ID的所有一级子分类
 		ArticleType arType = new ArticleType();
 		arType.setParentId(articleTypeList.get(0).getId());
 		List<ArticleType> arTypeList = currentService.findByModel(arType);
 		//判断该文章类型下是否有一级子分类
 		if(arTypeList.size()<=0){
 			return new AjaxResult(AjaxResult.STATUS_ERR, null,"暂无数据");
 		}
 		return new AjaxResult(AjaxResult.STATUS_OK, null, "文章类型一级子分类", arTypeList, arTypeList.size());
	}
  
}